package com.netease.nie.controllers;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.netease.nie.base.cache.redis.Redis;
import com.netease.nie.base.cdn.CDNProperties;
import com.netease.nie.base.controllers.BaseController;
import com.netease.nie.config.AdminAreaProperties;
import com.netease.nie.config.CreditGradeProperties;
import com.netease.nie.config.PresentGiftProperties;
import com.netease.nie.constants.CachePrefixConstants;
import com.netease.nie.service.CountryService;
import com.netease.nie.service.CreditService;
import com.netease.nie.service.GiftCreditService;
import com.netease.nie.service.UserInfoService;
import com.netease.nie.service.UserService;

@RestController
@RequestMapping("/country")
public class UserController extends BaseController {

	private static Logger logger = Logger.getLogger(UserController.class);
	
	private static final String USER_CREDIT_PREFIX = CachePrefixConstants.UserPrefix.USER_CREDIT_PREFIX;
	
	private static final String USER_ACTIVATION_CODE_PREFIX = CachePrefixConstants.UserPrefix.USER_ACTIVATION_CODE_PREFIX;
	
	
	@Autowired
	private CountryService countryService;
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private UserInfoService userInfoService;
	
	@Autowired
	private CreditService creditService;
	
	@Autowired
	private Redis redis;
	
	@Autowired
	private CreditGradeProperties creditGradeProperties;
	
	@Autowired
	private PresentGiftProperties presentGiftProperties;
	
	@Autowired
	private GiftCreditService giftCreditService;
	
	@Autowired
	private AdminAreaProperties adminAreaProperties;
	
	@Autowired
	private CDNProperties cdnConfig;
	
	
	@RequestMapping("/listAll")  
    public String view() throws Exception {
		redis.set("hunter1", "12313131231233");
		String h = redis.get("hunter1");
		String j = redis.get("hunter2");
		System.out.println(h);
		System.out.println(j);
		redis.incrBy("aaa", 10L);
		String aaa = redis.get("aaa");
		System.out.println(aaa);
		return jsonSuccess(countryService.listAllCountry());
		//return Collections.EMPTY_LIST;
		
    }
	
	@RequestMapping("/add")
	public int add() throws Exception {
		/*DataOperation dataOperation = new DataOperation() {
			
			public Object operate() {
				System.out.println("1111111111");
				List<Integer> list = new ArrayList<>();
				list.add(1);
				list.add(3);
				return list;
			}
		};
		List<String> keyList = new ArrayList<>();
		keyList.add("Goods_Stock_1");
		keyList.add("Goods_Stock_2");
		CacheParam cacheParam = new CacheParam();
		cacheParam.setKeyList(keyList);
		cacheParam.setPrefix("Goods_Stock_");
		RedisManager redisManager = new RedisManager(cacheParam, dataOperation);
		List<Integer> list = redisManager.passiveOperateCache(null);
		System.out.println(list);*/
		return countryService.addCountry();
	}
	
	@RequestMapping("/query")
	public String queryCountryById(int displayPeriod) throws Exception {
		return "1";
	}
	
}
